<!--#INCLUDE FILE="config.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link type="text/css" href="../css/jquery-ui-1.8.21.custom.css" rel="stylesheet" />
<script type="text/javascript" src="../js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="../js/jquery-ui-1.8.21.custom.min.js"></script>
<script language='JavaScript'>
	function refreshParent() {
		window.opener.location.href = window.opener.location.href;
		if (window.opener.progressWindow) {
			window.opener.progressWindow.close()
		}
		window.close();
	}
</script>
				
</head>
<%
if (Request("historyName") <> "") then
	iHs	= Request("historyName")
	guestId = Request("guestId")
	x = Split(iHs,"_")
	
	sqlstring = ""
	
	if (x(1) = 1) then
		sqlstring = sqlstring & "SELECT DISTINCT Historys.*, Users.UserName "
		sqlstring = sqlstring & "FROM Historys "
		sqlstring = sqlstring & "INNER JOIN Users on Historys.UserID = Users.UserID "
		sqlstring = sqlstring & "WHERE Historys.GuestID = "&guestId&" AND IsNote = 1 order by Date DESC"
		
	else

		sqlstring = ""
		sqlstring = sqlstring & "SELECT DISTINCT Historys.*, Users.UserName "
		sqlstring = sqlstring & "FROM Historys "
		sqlstring = sqlstring & "INNER JOIN Users on Historys.UserID = Users.UserID "
		sqlstring = sqlstring & "WHERE Historys.GuestID = "&guestId&" AND Historys.HistoryID = '"&x(0)&"'"
	
	end if
	
	dim count
	
	dim notes, strItem
	SET notes = CreateObject("Scripting.Dictionary")
	count = 0
	
	set objConnect1 = server.createObject("ADODB.Connection")   

	objConnect1.Open conStr

	set TblTemp1 = server.createobject("Adodb.Recordset")
		
		TblTemp1.Open sqlstring, objConnect1
		
	Do Until TblTemp1.EOF 
	count = count + 1

		NameDecrypt = ""
		TitleDecrypt = ""
			
			On Error Resume Next
			NameDecrypt = objEncrypter.Decrypt( TblTemp1("Name") )
			TitleDecrypt = objEncrypter.Decrypt( TblTemp1("TitleNote") )
			if (IsNull (historyNameDecrypt) or historyNameDecrypt = "") then
				Name = TblTemp1("Name")
				TitleNote = TblTemp1("TitleNote")
			else 
				Name = NameDecrypt
				TitleNote = TitleDecrypt
			end if
		
		DateHistory = TblTemp1("Date")
		UpdatedBy = TblTemp1("UserName")
		ContentNote = TblTemp1("DescriptionsNote")
		
		'Add to dictionary
		notes.Add ""&count, Array(Name,TitleNote, ContentNote,DateHistory,UpdatedBy)
			
	TblTemp1.MoveNext
	Loop 
	
end if
%>

<body>
<h2>History Detail!</h2>
 <table id="list_table" width="100%" border="0" cellspacing="0" cellpadding="5">
  <tr class="titles">
    <td>Name</td>
    <td>Title Note</td>
    <td>Content Note</td>
	<td>Updated By</td>
	<td>Updated Date</td>
  </tr>
  <%
For Each strItem In notes
%>  
  <tr>
	<td><%=notes(strItem)("0")%></td>
	<td><%=notes(strItem)("1")%></td>
	<td><%=notes(strItem)("2")%></td>
	<td><%=notes(strItem)("4")%></td>
	<td><%=notes(strItem)("3")%></td>
  </tr>
 <%Next%> 
  </table>
</body>
</html>